home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* Project...: Standard C++ Library */
- /* Name......: exception */
- /* Purpose...: exception handling */
- /* Copyright.: ©Copyright 1993-95 by metrowerks inc */
- /************************************************************************/
-
- #ifndef _EXCEPTION_
- #define _EXCEPTION_
-
- ////// Plauger Exceptions Start //////
- #include <defines>
-
- #if __MWERKS__
- #pragma options align=mac68k
-
- #if __CFM68K__ && __USING_IMPORTED_ANSI__
- #pragma import on
- #endif
- #endif
-
- // class xmsg
- class xmsg {
- public:
- typedef void(*raise_handler)(xmsg&);
- static raise_handler set_raise_handler(raise_handler);
- xmsg(const char * = 0, const char * = 0, const char * = 0);
- xmsg(const xmsg&);
- xmsg& operator=(const xmsg&);
- virtual ~xmsg();
- void raise();
- const char *what() const;
- const char *where() const;
- const char *why() const;
- static void _Throw(xmsg *);
- protected:
- virtual void do_raise();
- xmsg(const char *, const char *, const char *, _Bool);
- private:
- void _Tidy();
- static raise_handler _Handler;
- const char *_What, *_Where, *_Why;
- _Bool _Alloced;
- };
- // class xlogic
- class xlogic : public xmsg {
- public:
- xlogic(const char * = 0, const char * = 0, const char * = 0);
- virtual ~xlogic();
- protected:
- virtual void do_raise();
- };
- // class xruntime
- class xruntime : public xmsg {
- public:
- xruntime(const char * = 0, const char * = 0,
- const char * = 0);
- virtual ~xruntime();
- protected:
- xruntime(const char *, const char *, const char *, _Bool);
- virtual void do_raise();
- };
- // class badcast
- class badcast : public xlogic {
- public:
- badcast(const char * = 0, const char * = 0, const char * = 0);
- virtual ~badcast();
- protected:
- virtual void do_raise();
- };
- // class invalidargument
- class invalidargument : public xlogic {
- public:
- invalidargument(const char * = 0, const char * = 0,
- const char * = 0);
- virtual ~invalidargument();
- protected:
- virtual void do_raise();
- };
- // class lengtherror
- class lengtherror : public xlogic {
- public:
- lengtherror(const char * = 0, const char * = 0,
- const char * = 0);
- virtual ~lengtherror();
- protected:
- virtual void do_raise();
- };
- // class outofrange
- class outofrange : public xlogic {
- public:
- outofrange(const char * = 0, const char * = 0,
- const char * = 0);
- virtual ~outofrange();
- protected:
- virtual void do_raise();
- };
- // class overflow
- class overflow : public xruntime {
- public:
- overflow(const char * = 0, const char * = 0,
- const char * = 0);
- virtual ~overflow();
- protected:
- virtual void do_raise();
- };
- // class xdomain
- class xdomain : public xlogic {
- public:
- xdomain(const char * = 0, const char * = 0, const char * = 0);
- virtual ~xdomain();
- protected:
- virtual void do_raise();
- };
- // class xrange
- class xrange : public xruntime {
- public:
- xrange(const char * = 0, const char * = 0, const char * = 0);
- virtual ~xrange();
- protected:
- virtual void do_raise();
- };
- #if __MWERKS__
- #if __CFM68K__ && __USING_IMPORTED_ANSI__
- #pragma import reset
- #endif
-
- #pragma options align=reset
- #endif
- ////// Plauger Exceptions End //////
-
- #ifndef _STDEXCEPT_
- #include <stdexcept>
- #endif
-
- #if __MWERKS__
- #pragma options align=mac68k
-
- #if __CFM68K__ && __USING_IMPORTED_ANSI__
- #pragma import on
- #endif
- #endif
-
- class bad_exception : public exception {
- public:
- bad_exception() throw() {}
- bad_exception(const bad_exception&) throw() {}
- bad_exception& operator=(const bad_exception&) throw() { return *this; }
- // virtual ~bad_exception() throw();
- virtual const char* what() const /*throw()*/;
- };
-
- typedef void (*terminate_handler)();
- terminate_handler set_terminate(terminate_handler);
- void terminate();
-
- typedef void (*unexpected_handler)();
- unexpected_handler set_unexpected(unexpected_handler);
- void unexpected();
-
- #if __MWERKS__
- #if __CFM68K__ && __USING_IMPORTED_ANSI__
- #pragma import reset
- #endif
-
- #pragma options align=reset
- #endif
-
- #endif
-